package com.easy.modules.sysmgr.web.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.easy.common.util.Const;
import com.easy.common.web.BaseController;
import com.easy.common.web.page.DataGrid;
import com.easy.common.web.page.Msg;
import com.easy.modules.sysmgr.service.PermitsServiceI;
import com.easy.modules.sysmgr.web.form.PermitsForm;

@Controller
@RequestMapping("/sysmgr/permits")
public class PermitsAction extends BaseController {

	@Autowired
	private PermitsServiceI permitsService ;
	
	@RequestMapping("/permits_main.do")
	public String permits_main(){
		return  Const.SYSMGR + "permits_main" ;
	}
	
	@RequestMapping("/permits_form.do")
	public String permits_form(PermitsForm form, Model mode){
		if(null != form.getId() && !"".equals(form.getId())) {
			mode.addAttribute("id", form.getId()) ;
		}
		return Const.SYSMGR + "permits_form" ;
	}
	
	@RequestMapping("/permits_menu_page.do")
	public String permits_menu_add_page(PermitsForm form, Model mode){
		mode.addAttribute("permit", this.permitsService.getRoleMenus(form)) ;
		return Const.SYSMGR + "permits_menu_page" ;
	}
	
	@RequestMapping("/permits_workgroup_page.do")
	public String permits_group_add_page(PermitsForm form, Model mode){
		mode.addAttribute("permit", this.permitsService.getPermits(form)) ;
		return Const.SYSMGR + "permits_workgroup_page" ;
	}
	
	@RequestMapping("/permits_userrole_page.do")
	public String permits_userrole_page(PermitsForm form, Model mode){
		mode.addAttribute("permit", this.permitsService.getPermits(form)) ;
		return Const.SYSMGR + "permits_userrole_page" ;
	}
	
	@RequestMapping("/permits_user_page.do")
	public String permits_user_add_page(PermitsForm form, Model mode){
		mode.addAttribute("permit", this.permitsService.getPermitsUsers(form)) ;
		return Const.SYSMGR + "permits_user_page" ;
	}
	
	@RequestMapping("/get.do")
	@ResponseBody
	public PermitsForm get(PermitsForm form){
		return this.permitsService.get(form) ;
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	synchronized public Msg add(PermitsForm form){
		return this.permitsService.save(form) ;
	}
	
	@RequestMapping("/edit.do")
	@ResponseBody
	public Msg edit(PermitsForm form){
		return this.permitsService.edit(form) ;
	}
	
	@RequestMapping("/delete.do")
	@ResponseBody
	public Msg delete(PermitsForm form){
		return this.permitsService.delete(form) ;
	}
	
	@RequestMapping("/datagrid.do")
	@ResponseBody
	public DataGrid datagrid(PermitsForm form){
		return this.permitsService.datagrid(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_datagrid.do")
	@ResponseBody
	public DataGrid doNotNeedAuth_datagrid(PermitsForm form){
		return this.permitsService.datagrid(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_addMenus_role.do")
	@ResponseBody
	public Msg addMenus_role(PermitsForm form){
		return this.permitsService.addMenuRole(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_addWorkGroups.do")
	@ResponseBody
	public Msg addpermits_groups(PermitsForm form){
		return this.permitsService.addWorkGroupPermits(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_addUserRole.do")
	@ResponseBody
	public Msg doNotNeedAuth_addUserRole(PermitsForm form){
		return this.permitsService.addUserRolePermits(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_addPermits_Users.do")
	@ResponseBody
	public Msg addpermits_users(PermitsForm form){
		return this.permitsService.addUserPermits(form) ;
	}
	

	
}
